<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<style>
    .iconchange1 .fa{
        color: #2a6496;
        font-size: 12px!important;
    }
    .businessBtns .basicInfoBtnt:nth-child(2){
        background-color: #23a8f5!important;
        color: #fff!important;
    }
    .businessBtns .basicInfoBtnt:nth-child(1){
        background-color: #fff!important;
        color: #4a647d!important;
    }
</style>
<div class="row margin-left-10">
    <input type="hidden" id="type" value="${type}">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="widget searchCriteria flat margin-top-0" style="margin: -10px 0 0px 0!important;">
            <div class="widget-header bordered-sky theme-bordered nopadding">
                <div class="widget-buttons widget-label nomargin-bottom">
                    <label class="businessBtns">
                        <ol class="breadcrumb" style="margin: 0;">
                            <li style="color: #809fa6;">考勤管理</li>
                            <li class="active" style="color: #23a8f5;">考勤维护</li>
                        </ol>
                    </label>
                </div>
            </div>
        </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 margin-bottom-10">
        <div class="widget searchCriteria flat margin-top-0" style="margin: 3px 0 0px 0!important;">
            <div class="widget-header bordered-sky theme-bordered nopadding">
                <div class="widget-buttons widget-label nomargin-bottom">
                    <label class="businessBtns">
                        <@hp code="KQWH18034537270052-qz_attendance_maintenance" />
                        <@hp code="KQWH18034537270052-gd_attendance_maintenance" />
                        <!--<a type="btn" class="btn basicInfoBtnt parentChildBtn"
                           style="background-color: #23a8f5;border: none;border-top-left-radius: 4px!important;border-bottom-left-radius: 4px!important;width: 120px;color: #fff;margin-right: 0!important;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
                            亲子考勤维护
                        </a>
                        <a type="btn" class="btn basicInfoBtnt interimBtn"
                           style="border: none;border-top-right-radius: 4px!important;border-bottom-right-radius: 4px!important;width: 120px;color: #4a647d;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
                            过渡考勤维护
                        </a>-->
                    </label>
                    <label class="pull-right businessBtns">
                        <label class="">
                            <!--<a style="border-radius: 0px;border: none;background: #23a8f5 !important;margin-right: 25px;"
                              class="btn btn-blue shiny download"><i class="fa fa-download"></i>导入</a>-->
                            <@hp code="KQWH18034537270052-exportData_gd"  params="[searchFormId=${searchFormId}]" />
                            <a style="border-radius: 0px;border: none;background: #ffab00 !important;margin-right: 25px;"
                               class="btn btn-warning shiny search "><i class="fa fa-search"></i>搜索
                            </a>
                        </label>
                        <label onclick="iconsChange()" >
                            <label>
                                <a class="iconsChangeA" style="width: 13px;height: 13px;cursor: pointer;background: url('assets/img/nav-img/icon_hidden.png');display: block;-webkit-user-select:none; -moz-user-select:none; -ms-user-select:none;user-select:none;" value="1"></a>
                            </label>
                            <label style="color: #23a8f5 ;vertical-align: middle;padding-top:4px;">
                                <span class="iconsChangeSpan" style="-webkit-user-select:none; cursor: pointer;-moz-user-select:none; -ms-user-select:none;user-select:none;">隐藏搜索栏</span>
                            </label>
                        </label>
                    </label>
                </div>
            </div>
        </div>
    </div>
    <!-- 映射列表 -->
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" >
        <div class="search_Bar" style="vertical-align: middle">
            <form id="${searchFormId}" action="${actionUrl}" class="searchConditions" method="POST">
                <div class="row searchInput" style="margin: 0;">
                    <label class="iconchange1 hidden" style="position: absolute;right: 10px;top: 0px;" >
                        <a class="search_Bar_A" id="iconchangemore" style="color: #2a6496;cursor: pointer;" onclick="iconchangeShow(this)" value="1">筛选更多<i class="fa fa-chevron-down" style="padding-left: 5px"></i></a>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">会员姓名：</label>
                        <label>
                            <input type="text" name="studentName" value="${search_map.studentName[0]}" placeholder="请输入会员姓名" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">联系电话：</label>
                        <label>
                            <input type="text" name="contactPhone" value="${search_map.contactPhone[0]}" placeholder="请输入联系电话" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;">
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">体系名称：</label>
                        <label>
                            <select class="form-select-1 courseSystemName" name="type" id="courseSystemName" value="${search_map.courseSystemName[0]}"
                                    style="width:200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" >
                            </select>
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">课程名称：</label>
                        <label>
                            <select class="form-select-1 courseId" name="courseName" value="${search_map.courseName[0]}"
                                    style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" >
                                <option value="">请先选择课程体系</option>
                            </select>
                        </label>
                    </label>
                    <label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
                        <label style="width: 78px">日期范围：</label>
                        <label>
                            <input type="text" id="d4311" name="createTime_begin" class="beginValue Wdate" value="${search_map.createTime_begin[0]}" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;" onFocus="WdatePicker({doubleCalendar:true,maxDate:'#F{$dp.$D(\'d4312\')}',dateFmt:'yyyy-MM-dd'})"> 至
                            <input id="d4312"  type="text" name="createTime_end" class="endValue Wdate"  value="${search_map.createTime_end[0]}" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;" onFocus="WdatePicker({doubleCalendar:true,minDate:'#F{$dp.$D(\'d4311\')}',dateFmt:'yyyy-MM-dd '})">
                        </label>
                    </label>
                </div>
            </form>
        </div>
        <div class="widget flat radius-bordered" style="margin-top: 0px;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
            <div class="widget-body no-padding">
                <div class="topPagingBar hidden">
                    ${pagingBar}
                </div>
                <div class="table-scrollable" style="border: none;">
                    <!-- 数据表列信息列表 -->
                    <table class="table table-hover dataTable newtable">
                        <thead>
                        <tr>
                            <th title="选择" class="checkboxColumnTh">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" class="chkAll">
                                        <span class="text"></span>
                                    </label>
                                </div>
                            </th>
                            <th title="属性名">序号</th>
                            <th title="操作">操作</th>
                            <th title="会员姓名">会员姓名</th>
                            <th title="联系电话">联系电话</th>
                            <th title="会员类型">会员类型</th>
                            <th title="课程名称">课程名称</th>
                            <th title="上课日期">上课日期</th>
                            <th title="上课时间">上课时间</th>
                            <th title="授课老师">授课老师</th>
                            <th title="当前周次">当前周次</th>
                            <th title="考勤状态">考勤状态</th>
                            <!--<th title="考勤退课后状态">考勤退课后状态</th>-->
                            <th title="课程权责">课程权责</th>
                            <th title="权责消耗">权责消耗</th>
                            <th title="当前消耗课时包">当前消耗课时包</th>
                            <th title="课时类型">课时类型</th>
                            <th title="最后操作人">最后操作人</th>
                            <th title="最后操作日期">最后操作日期</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#if page_bean.list?size==0>
                            <tr>
                                <td align="center">无数据</td>
                            </tr>
                        </#if>
                        <@dictionary groupCode="attendenceStatus";dics>
                        <#list page_bean.list as data>
                            <tr>
                                <td class="checkboxColumnTd">
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" class="chk" name="chk" value="${data.id}"
                                                   createTime="${data.memberCheckAttendanceCreateTime}">
                                            <span class="text"></span>
                                        </label>
                                    </div>
                                </td>
                                <td>${data_index+1+(page_bean.pageNo-1)*page_bean.pageSize}</td>
                                <td class="methodsTd">
                                    <@hp code="KQWH18034537270052-list_class_attendance_gd" params="[attendanceId=${data.id}]" />
                                  </td>
                                <td >${(data.studentName???string(data.studentName?html,"未设置"))!'未设置'}</td>
                                <td>${(data.contactPhone???string(data.contactPhone?html,"未设置"))!'未设置'}
                                <td>${(data.type???string(data.type?html,"未设置"))!'未设置'}
                                <td>${(data.courseName???string(data.courseName?html,"未设置"))!'未设置'}
                                <td class="tdCreateTime">${(data.createTime???string(data.createTime?html,"未设置"))!'未设置'}
                                <td>
                                    ${(data.startTime???string(data.startTime?html,"未设置"))!'未设置'}-
                                    ${(data.endTime???string(data.endTime?html,"未设置"))!'未设置'}
                                </td>
                                <td>${(data.realName???string(data.realName?html,"未设置"))!'未设置'}</td>
                                <td>周次</td>
                                <td class="changeStatusTd">
                                    ${(data.attendenceStatus???string(data.attendenceStatus?html,"无"))!'未设置'}
                                </td>
                                <td>${(data.classAmount???string(data.classAmount?html,"未设置"))!'未设置'}</td>
                                <td>${(data.amount???string(data.amount?html,"未设置"))!'未设置'}</td>
                                <td>${(data.packageName???string(data.packageName?html,"未设置"))!'未设置'}</td>
                                <td>
                                    ${(data.formalClass???string(data.formalClass?html,"未设置"))!'未设置'}
                                    ${(data.giftClass???string(data.giftClass?html,"未设置"))!'未设置'}
                                </td>
                                <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                <td>
                                    ${(data.updateTime???string(data.updateTime?html,"未设置"))!'未设置'}
                                </td>
                            </tr>
                        </#list>
                        </@dictionary>
                        </tbody>
                    </table>
                </div>
                ${pagingBar}
            </div>
        </div>
    </div>
</div>
<script>

    $(function(){

        /**
         * 获取课程体系
         */
        $(function(){
            ajaxRequest("sysCourseSystemController/courseSystemList.do",{
                type:1
            }, function (result) {
                var data=result.data;
                var arr=['<option value="">请选择</option>'];
                $.each(data,function(i,t){
                    arr.push('<option value="'+t.id+'">'+t.name+'</option>')
                })
                $("#courseSystemName").html(arr.join(''))
            },function(){
                ajaxError("加载课程体系失败");
            }, "get","json")
        });

        /**
         * 获取课程体系下课程名称
         */
        $("#courseSystemName").change(function(){
            var nowSelectedProvince=$(this).val();
            ajaxRequest("sysCourseSystemController/getChildrens.do", {
                pId: nowSelectedProvince,
            }, function (result) {
                var data=result.data;
                var arr=['<option value="">请选择</option>'];
                $.each(data,function(i,t){
                    arr.push('<option value="'+t.id+'">'+t.name+'</option>')
                })
                $(".courseId").html(arr.join(''))

            }, function () {
                ajaxError("加载课程名称失败")
            }, "get", "json")
        });

    });

    $(".selectpicker").select2();

    $(".parentChildBtn").click(function () {
        $("#type").val(2);
        javascript:toView('tssMemberCheckAttendanceController/viewAttendanceMaintenanceList.do', true, 'POST', {pageSize: 10})
    })
    $(".interimBtn").click(function () {
        $("#type").val(1);
        javascript:toView('tssMemberCheckAttendanceController/transitionViewAttendanceMaintenanceList.do', true, 'POST', {pageSize: 10})
        $(function () {
            var type = $("#type").val();
            if (type == 2) {
                $('.interimBtn').css("background", "#5db2ff");
                $('.parentChildBtn').css("background", "#fff");
            }
        });
    })

    //显示当天时间
    //    setInterval("cg.value=new Date().toLocaleString()",1000);
    var trs = $("#setTimeTbody tr");
    trs.each(function (trindex, tritem) {//遍历每一行

        $(tritem).find(".changeStatusTd").each(function (tdindex, tditem) {
            var $td = $(tditem);
            var val = $td.html();
            var timeVal = $td.parents("tr").find(".tdCreateTime").html();
            var nowTime = new Date();
            console.log(nowTime)
            var urodz = new Date(timeVal);
            console.log(urodz);
            var sum = nowTime - urodz;
            console.log(sum);
            if ((val == 1 || val == 3) && sum >= 86400) {
                $(this).parent("tr").find(".methodsTd a").removeClass("hidden");
            } else {
                $(this).parent("tr").find(".methodsTd a").addClass("hidden");
            }
        });


    });

    /**
     * 考勤退课
     * @param that
     */
    function withdrawal(that) {
        var attendanceId = $(that).attr("attendanceId");
        ajaxRequest("tssMemberCheckAttendanceController/viewAttendanceMaintenanceListEditView.do", {
            attendanceId: attendanceId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "考勤退课",
                className: 'myDialog '
            });

        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")
    }


// 考勤退课
    function classAttendance(that) {
        var attendanceId = $(that).attr("attendanceId");
        ajaxRequest("tssMemberCheckAttendanceController/ViewAttendanceMaintenanceListEditView.do", {
            attendanceId: attendanceId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "考勤退课",
                className: 'myDialog tssMemberCheckAttendanceDialog'
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")

    }

    //    隐藏显示搜索
    function iconsChange() {
        if($(".iconsChangeA").val()==1){
            $(".iconsChangeA").val("0");
            $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_hidden.png')");
            $(".iconsChangeSpan").html("隐藏搜索栏");
            $(".search_Bar").removeClass("hidden");
        }else{
            $(".iconsChangeA").val("1");
            $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_show.png')");
            $(".iconsChangeSpan").html("显示搜索栏");
            $(".search_Bar").addClass("hidden");
        }
    }

    //    筛选下拉框
    setTimeout(function () {
        var size = $(".search_Bar_item").size();
        if (size > 8) {
            $(".iconchange1").removeClass("hidden");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }

            })
        } else {
            $(".iconchange1").addClass("hidden");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }

        $(".iconDialogTd").each(function (tr,trItem) {
            var $tr = $(trItem);
            var sizeTd = $tr.find(".showDialogTd").size();
            if(sizeTd>5){
                $tr.find(".iconchangeTd").removeClass("hidden");
                $tr.find(".showDialogTd").each(function (a,aItem) {
                    var $a = $(aItem);
                    if(($a.index()+1)>5){
                        var html = $a.get(0);
                        $a.remove();
                        $tr.find(".popover-content").get(0).append(html);
                        $a.addClass("appendTdA")

                    }
                })

            }else{
                $tr.find(".iconchangeTd").addClass("hidden");
                $tr.find(".showDialogTd").each(function () {
                    $tr.removeClass("hidden");
                })
            }
        })

    }, 10);

    function iconchangeShow(that) {

        if($(that).attr("value")==1){
            $(that).attr("value","0");
            $(".iconchange1 .fa").removeClass("fa-chevron-down").addClass("fa-chevron-up");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }else{
            $(that).attr("value","1");
            $(".iconchange1 .fa").removeClass("fa-chevron-up").addClass("fa-chevron-down");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }else{
                    $(this).addClass("hidden")
                }

            })
        }

    }

</script>